package com.zywl.utils.utils.enums;

import com.zywl.utils.utils.RegexUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: 杨帆
 * @Date: 2018/12/3 16:37
 * @Description:
 */
public enum DataPermissionEnum {
    ALL_CITY("1", "全台州市数据"), ALL_COUNTY("2", "全县市区数据"), ALL_STREET("3", "全乡镇街道数据"), ALL_UNIT("4", "全单位数据"), PERSONAL("5", "个人数据");

    private final String key;
    private final String value;

    DataPermissionEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static List<Map<String, Object>> getSmaller(String level) {
        if (RegexUtil.isNumber(level)) {
            List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
            Map<String, Object> map = null;
            String key = null;
            for (DataPermissionEnum en : DataPermissionEnum.values()) {
                key = en.getKey();
                if (Short.valueOf(en.getKey()) >= Short.valueOf(level)) {
                    map = new HashMap<String, Object>();
                    map.put("key", key);
                    map.put("value", en.getValue());
                    list.add(map);
                }
            }
            return list;
        }
        return null;
    }
}
